import {useRoute} from 'vue-router'
import {reactive} from "vue";
import {useStorage} from "@/hooks/web/useStorage";

export const usePermissions = () => {
    const permissions = reactive({})
    const route = useRoute()
    const {getStorage} = useStorage()
    const isAdmin = getStorage('userInfo').is_admin
    const fetchPermissions = () => {
        let permissionsArr = getStorage('roleButtons')
        console.log(permissionsArr);return
        permissionsArr.forEach(item => {
            let itemArr = item.split('_')
            if (itemArr[0] === route.path) {
                permissions[itemArr[1]] = true
            }
        })
        console.log('permissions', permissions);
    }

    return {
        isAdmin,
        permissions,
        fetchPermissions,
    }

}